from pydantic import BaseModel, Field
from typing import List, Optional, Dict, Any
from datetime import datetime

class ChatMessage(BaseModel):
    role: str = Field(..., description="Role of the message sender")
    content: str = Field(..., description="Content of the message")

class ChatRequest(BaseModel):
    messages: List[ChatMessage] = Field(..., description="List of chat messages")
    model: str = Field("gpt-3.5-turbo", description="Model to use for chat")
    temperature: Optional[float] = Field(0.7, ge=0.0, le=2.0, description="Temperature for generation")
    max_tokens: Optional[int] = Field(1000, ge=1, le=4000, description="Maximum tokens to generate")

class ChatResponse(BaseModel):
    message: ChatMessage = Field(..., description="AI response message")
    model: str = Field(..., description="Model used for generation")
    usage: Optional[Dict[str, int]] = Field(None, description="Token usage information")
    processing_time: Optional[float] = Field(None, description="Processing time in seconds")

class ModelInfo(BaseModel):
    name: str = Field(..., description="Model name")
    description: str = Field(..., description="Model description")
    max_tokens: int = Field(..., description="Maximum context length")
    is_available: bool = Field(..., description="Whether the model is available")

class SystemStatus(BaseModel):
    status: str = Field(..., description="System status")
    active_models: List[str] = Field(..., description="List of active models")
    total_requests: int = Field(..., description="Total requests processed")
    uptime: float = Field(..., description="System uptime in seconds")

class HealthCheck(BaseModel):
    status: str = Field(..., description="Health status")
    timestamp: datetime = Field(..., description="Check timestamp")
    version: str = Field(..., description="API version")